package com.qf.controller;

import com.qf.entity.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (User)表控制层
 *
 * @author makejava
 * @since 2020-05-21 16:36:43
 */
@RestController
@RequestMapping("/user")
public class UserController {
    /**
     * 服务对象
     */
    @Autowired
     UserService userService;

    /**
     * 查找全部
     * @return
     */
    @RequestMapping("/findAll")
    public List<User> findAll() {

        return userService.findAll();
    }

    /**
     * 查找一个
     * @param uid
     */

    @GetMapping("/getUserByUid/{uid}")
    public User getUserByUid(@PathVariable Integer uid) {
        return userService.queryById(uid);
    }

    /**
     * 添加
     * @param user
     */


    @RequestMapping(value = "/SaveUsers",method = RequestMethod.POST)
    public void saveUser(@RequestBody User user){
        userService.insert(user);
    }



    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public String update(@RequestBody User user){
        return userService.update(user);
    }
  @RequestMapping(value = "/del",method = RequestMethod.POST)
    String deleteById(@RequestBody User user){
        Integer uid=user.getUid();
       return userService.deleteById(uid);
    }


}